<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 返回字符串中最长的连续重复字母mmmiijjjjkkkkkkssptr返回"kkkkkk"
        let string = 'mmmiijjjjkkkkkkssptr'
        let arr = []
        for (let i = 0; i < string.length; i++) {
            arr.push(string[i])
        }
        let obj = {}
        arr.map(item => {
            if (obj[item]) {
                obj[item] += 1
            } else {
                obj[item] = 1
            }
        })
        console.log(obj)
        let max = 0
        let i = ''
        for (let k in obj) {
            // console.log(k)
            if (max < obj[k]) {
                max = obj[k]
                i = k
            }
        }
        console.log(obj[i]);
        let st = ''
        for (let j = 0; j < obj[i]; j++) {
            st = st + i
        }
        console.log(st)
    </script>
</body>

</html>